package com.nslt.controller;

import com.nslt.entity.Users;
import com.nslt.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class MainController {

    @Autowired
    private UsersService usersService;

    @RequestMapping("/")
    public String index(){
        return "index";
    }

    @RequestMapping("/find")
    public String fin(){
        List<Users> users = new ArrayList<Users>();
        users = usersService.findAllUsers();
        System.out.println(users.size());
        return "index";
    }


    /*@RequestMapping(value="/users",method= RequestMethod.POST,produces="application/json;charset=UTF-8")
    public @ResponseBody Object add(Users vo){
        //log.info("数据增加成功："+vo);
        System.out.println("数据增加成功："+vo);
        //JSONObject js = new JSONObject();
        //JSONObject json=new JSONObject();
        //js.put("flag", true);
        List<Users> users = new ArrayList<Users>();
        users = usersService.findAllUsers();
        System.out.println(users.size());
        //return js;
        return "index";
    }*/
}
